<template>
  <div class="panel">
    <div class="panel-header" v-if="title || $slots.title || $slots.footer">
      <div>
        <slot name="title">
          <SvgIcon class="panel-header-icon" :name="icon" />
          <span class="panel-header-title">{{ title }}</span>
        </slot>
      </div>
      <div>
        <slot name="action"></slot>
      </div>
    </div>
    <div class="panel-body">
      <slot></slot>
    </div>
    <div class="panel-footer" v-if="$slots.footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Panel',
  props: {
    title: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: ''
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'styles/common.scss';
.panel {
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: $colorWhite;
  border-radius: $borderRadius;
  .panel-header {
    height: 50px;
    padding: 0 0.67rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid $colorBorder2;
    .panel-header-title {
      font-size: 16px;
      color: $colorText1;
    }
    .panel-header-icon {
      position: absolute;
      left: 0.35rem;
      font-size: 16px;
      color: $colorPrimary;
    }
  }
  .panel-body {
    padding: 0.33rem 0.67rem;
    flex: 1;
    height: 100%;
    position: relative;
  }
  .panel-footer {
    height: 50px;
    padding: 0 $horPadding;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid $colorBorder2;
  }
}
</style>
